#!/bin/sh
# filename: ddoctype
# description: create doctype

#     Copyright © 2012-2013 Toan Nguyen <toan.nguyen@monash.edu>
#
#     This file is part of Xglom.
# 
#     This is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
# 
#     This is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with this program.  If not, see <http://www.gnu.org/licenses/>.


. dcheck

update_dic() {
    dic_name=$1
	shift
	dic_des=$1
	shift
	dic_entries=$*
	echo ${dic_name} ${dic_des} ${dic_entries}
	
	exist=$($MFCOMMAND dictionary.exists :name ${dic_name} | awk '{print $4}' | tr -d \")
    if [ ${exist} = "true" ]; then
	    $MFCOMMAND dictionary.destroy :name ${dic_name}
    fi
    $MFCOMMAND dictionary.create :name ${dic_name} :case-sensitive true
    $MFCOMMAND dictionary.add :dictionary ${dic_name} ${dic_entries}
}

# :name "mbi.animal.sex"
dic_name="mbi.animal.sex"
dic_des="mbi.animal.sex"
dic_entries=":entry < :term Female > :entry < :term Male > :entry < :term Unknown >"
update_dic ${dic_name} ${dic_des} ${dic_entries}

# :name "mbi.kidney.emdedding"
dic_name="mbi.kidney.emdedding"
dic_des="mbi.kidney.emdedding"
dic_entries=":entry < :term LMP agarose 1% > :entry < :term LMP agarose 1% + 4% PFA > :entry < :term LMP agarose 2% > :entry < :term LMP agarose 2% + 4% PFA >"
update_dic ${dic_name} ${dic_des} ${dic_entries}

# :name "mbi.kidney.fixative"
dic_name="mbi.kidney.fixative"
dic_des="mbi.kidney.fixative"
dic_entries=":entry < :term 4% PFA > :entry < :term none >"
update_dic ${dic_name} ${dic_des} ${dic_entries}

# :name "mbi.kidney.im_duration"
dic_name="mbi.kidney.im_duration"
dic_des="mbi.kidney.im_duration"
dic_entries=":entry < :term 0 hrs > :entry < :term 12 hrs > :entry < :term 24 hrs > :entry < :term 6 hrs >"
update_dic ${dic_name} ${dic_des} ${dic_entries}

# :name "mbi.kidney.protocol"
dic_name="mbi.kidney.protocol"
dic_des="mbi.kidney.protocol"
dic_entries=":entry < :term 1 dose of CF > :entry < :term 2 doses of CF > :entry < :term 3 doses of CF > :entry < :term Mirofil perfusion >"
update_dic ${dic_name} ${dic_des} ${dic_entries}

# :name "mbi.kidneyspecies"
dic_name="mbi.kidneyspecies"
dic_des="mbi.kidneyspecies"
dic_entries=":entry < :term Mouse- KSJ > :entry < :term Mouse-BALB/C > :entry < :term Mouse-C57Bl/6 > :entry < :term Rabbit-New-Zealand-White > \
             :entry < :term Rat-Long-Evans > :entry < :term Rat-SHR > :entry < :term Rat-Sprague-Dawley > :entry < :term Rat-WKY > \
			 :entry < :term Rat-Wistar > :entry < :term Rat-Zucker > "
update_dic ${dic_name} ${dic_des} ${dic_entries}

# :name "mbi.subjectTypes"
dic_name="mbi.subjectTypes"
dic_des="mbi.subjectTypes"
dic_entries=":entry < :term animal > :entry < :term human > :entry < :term non-animal > "
update_dic ${dic_name} ${dic_des} ${dic_entries}

# :name "mbi.treatmentgroups"
dic_name="mbi.treatmentgroup"
dic_des="mbi.treatmentgroup"
dic_entries=":entry < :term Control > :entry < :term High Fat Diet > "
update_dic ${dic_name} ${dic_des} ${dic_entries}
